package org.duang.logs.db;

import ch.qos.logback.core.UnsynchronizedAppenderBase;

public abstract class DBAppenderBase<T, E> extends UnsynchronizedAppenderBase<E> {

	private ILogDBFactory<T> dbFactory;

	public DBAppenderBase() {
		
	}
	public DBAppenderBase(ILogDBFactory<T> factory) {
		this.dbFactory = factory;
	}
	
//	public DBAppenderBase(ILogDBFactory<T> factory) {
//		this.dbFactory = factory;
//	}

	@Override
	public void start() {
		super.start();
	}

	@Override
	protected void append(E eventObject) {
		dbFactory.insert(toObject(eventObject));
	}

	protected abstract T toObject(E eventObject);
}
